AI Verified

Name

Google tag added to head

About

Google tag code added to the head of the web site

Language

PHP

Rating

Voted: 1 by 1 user(s)

How to Setup Snippet

The following is an example of adding a Google tag. You will need to get the Google tag for your own web site. As the one I have added is meant for my tutorial site and is used only for that individual site.

Codevault

Easy Web Design Tutorials

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: Not Specified

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

21/02/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

-------------------------------------------------------------------------------------------------------------
Name | Potential vulnerability found : High Entropy String
Line | 6
Code | (<scriptasyncsrc="https://www.googletagmanager.com/gtag/js?id=G-N82M0N2BYX")
Code | Line | 6 : <scriptasyncsrc="https://www.googletagmanager.com/gtag/js?id=G-N82M0N2BYX"

Found 1 vulnerabilities

Google tag added to head

 
                    
1/* Adding Google tag code to head of the site. */
2add_action('wp_head', 'google_tag');
3function google_tag(){
4?>
5<!-- Google tag (gtag.js) YOU NEED TO GET YOUR OWN SITE SPECIFIC GOOGLE TAG -->
6<script async src="https://www.googletagmanager.com/gtag/js?id=G-N82M0N2BYX"></script>
7<script>
8 window.dataLayer = window.dataLayer || [];
9 function gtag(){dataLayer.push(arguments);}
10 gtag('js', new Date());
11 
12 gtag('config', 'G-N82M0N2BYX');
13</script>
14<!-- Google tag (gtag.js) END -->
15<?php
16};

1

Comments

  • E

    1 year ago

    This is working.

Related Snippets

Please see some snippets below related to this snippet..

Tracking - Analytics

AI Verified

0

Insert Google Analytics in Header

Added: 1 year ago

Last Updated: 1 year ago

Insert Google Analytics in Header

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WordPress Admin

AI Verified

1

Stop success email of plugin auto update.

Added: 1 year ago

Last Updated: 1 year ago

This code snippets will stop all auto update success e-mails from being sent out. It will only send out emails when a plugin update fails.

Tracking - Analytics

AI Verified

1

Google tag added to head

Added: 1 year ago

Last Updated: 1 year ago

Google tag code added to the head of the web site

General

AI Verified

1

Remove CTP name from URL slug

Added: 1 year ago

Last Updated: 1 year ago

Code removes the Custom Post Type (CPT) name from the URL slug.